/*
 * @Description: 因子库列表
 * @Author: chenju
 * @Date: 2022-01-19 10:47:42
 * @LastEditors: qingyang
 * @LastEditTime: 2023-06-28 18:25:04
 */

import { get, post } from '@/utils/http'
import type { BasicPagingListParams, BasicPagingListResult } from '@/apis/basicModel'
import type {
  GetEmissionListParams,
  GetEmissionListResult,
  createEmissionParams,
  updateStatusParams,
  batchUpdateStatusParams,
  batchUpdateStatusResult
} from './model/emissionListModel'

enum Api {
  // 排放源分页
  GET_EMISSION_LIST = '/inventory/emissionSource/page',
  CREATE_EMISSION = '/inventory/emissionSource/save',
  UPDATE_STATUS = '/inventory/emissionSource/updateStatus',
  BATCH_UPDATE_STATUS = '/inventory/emissionSource/batchUpdateStatus',
  // 修改排放源
  UPDATE_EMISSION = '/inventory/emissionSource/updateEmission',
  DEL_EMISSION = '/inventory/emissionSource/deleteEmission'
}

// 排放源分页
export const getEmissionList = (
  params: GetEmissionListParams & BasicPagingListParams
): Promise<BasicPagingListResult<GetEmissionListResult>> => get(Api.GET_EMISSION_LIST, params)

// 新建
export const createEmission = (params: createEmissionParams): Promise<void> =>
  post(Api.CREATE_EMISSION, params)

// 编辑
export const editEmission = (params: createEmissionParams): Promise<void> =>
  post(Api.UPDATE_EMISSION, params)
// 删除
export const delEmission = (sourceNo: string): Promise<void> => post(Api.DEL_EMISSION, { sourceNo })

// 修改因子状态
export const updateStatus = (params: updateStatusParams): Promise<void> =>
  post(Api.UPDATE_STATUS, params)

// 因子批量启用/停用
export const batchUpdateStatus = (
  params: batchUpdateStatusParams
): Promise<batchUpdateStatusResult> => post(Api.BATCH_UPDATE_STATUS, params)
